package com.example.tokendemo.controller;

import com.example.tokendemo.common.utils.ResultUtil;
import com.example.tokendemo.security.entity.SelfUserEntity;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.BindingResultUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping(value = "/info",method = RequestMethod.GET)
    public Map<String,Object> userLogin(){
        Map<String,Object> result = new HashMap<>();
        SelfUserEntity userDetails = (SelfUserEntity) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        result.put("title","用户端信息");
        result.put("data",userDetails);
        return ResultUtil.resultSuccess(result);
    }

    @RequestMapping(value = "/register",method = RequestMethod.GET)
    public Map<String, Object> userRegister(){
        Map<String, Object> result = new HashMap<>();

        return ResultUtil.resultSuccess(result);
    }
}
